import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:sprintf/sprintf.dart';

import '../../../../../shared/constants.dart';

class Schedule extends StatelessWidget {
  /// This widget displays the formatted [schedule]
  /// in a human-readable way.

  const Schedule({
    Key? key,
    required this.schedule,
    this.press,
  }) : super(key: key);

  final DateTime schedule;
  final Function()? press;

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(
          sprintf("%02d-%02d",[schedule.month,schedule.day]),
          style:const TextStyle(
            fontSize: miDefaultSize * 1.2,
            color: miTextBoldColor,
          ),
        ),
      const  SizedBox(width: miDefaultSize * 0.5),
        Text(
          DateFormat.Hm().format(schedule),
          style:const TextStyle(
            fontSize: miDefaultSize * 1.2,
            color: miTextColor,
          ),
        ),
       const SizedBox(width: miDefaultSize * 0.5),
        TextButton.icon(
          onPressed: press,
          icon:const Icon(
            Icons.delete_forever_rounded,
          ),
          label:const Text("删除"),
          style: TextButton.styleFrom(
              primary: Colors.red, backgroundColor: Colors.white),
        ),
      ],
    );
  }
}
